using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ChapterConfiguration : HOConfigurationReader
{
	public TextAsset table;

	protected Dictionary<int, ChapterInfo> mChapterDictionary = new Dictionary<int, ChapterInfo>();

	public static ChapterConfiguration instance
	{
		get;
		private set;
	}

	public static Dictionary<int, ChapterInfo> chapterDictionary => instance.mChapterDictionary;

	private void Awake()
	{
		if (instance == null)
		{
			instance = this;
			UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
			Read();
		}
		else
		{
			UnityEngine.Object.Destroy(this);
		}
	}

	public void OnApplicationQuit()
	{
		instance = null;
	}

	private void Read()
	{
		Hashtable hashtable = new Hashtable();
		ParseData(table, hashtable);
		IDictionaryEnumerator enumerator = hashtable.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				DictionaryEntry dictionaryEntry = (DictionaryEntry)enumerator.Current;
				ChapterInfo chapterInfo = new ChapterInfo();
				int num = 0;
				Hashtable hashtable2 = (Hashtable)dictionaryEntry.Value;
				chapterInfo.chapter = HOConfigurationReader.ParseTableValueToInt(hashtable2["ID"]);
				chapterInfo.name = HOConfigurationReader.ParseTableValueToString(hashtable2["Name"]);
				chapterInfo.imageName = HOConfigurationReader.ParseTableValueToString(hashtable2["ImageName"]);
				chapterInfo.titleName = HOConfigurationReader.ParseTableValueToString(hashtable2["TitleName"]);
				num = chapterInfo.chapter;
				mChapterDictionary.Add(num, chapterInfo);
			}
		}
		finally
		{
			IDisposable disposable;
			if ((disposable = (enumerator as IDisposable)) != null)
			{
				disposable.Dispose();
			}
		}
	}
}
